#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
#define N 10

void RunChiled()
{
    int cnt=5;
    while(cnt--)
    {
        printf("I am Child %d\n",getpid());
        sleep(1);
    }
}
int main()
{
    int i=0;
    for(;i<N;i++)
    {
        pid_t id=fork();
        if(id==0)
        {
            RunChiled();
            exit(0);
        }

        printf("create child process%d success\n",id);
    }

    int n=0;
    for(;n<N;n++)
    {
        pid_t ret=wait(NULL);
        if(ret>0)
        {
            printf("wait success ret=%d\n",ret);
        }
        sleep(2);
    }

    sleep(5);
    return 0;
}
